import request from "@/api/config/request.ts"
import type { ApiResponse } from "@/api/type.ts"

// 表结构
export interface RoleStructure {
  id: number
  name: string
  description: string
  status: number
}

// 返回数据定义
export interface RoleResponse {
  list: RoleStructure[]
  total: number
}

// 查询参数
export interface getRoleParams {
  page: number
  pageSize: number
}

export const getRoleListApi = (
  data: getRoleParams = { page: 1, pageSize: 10 }
): Promise<ApiResponse<RoleResponse>> => {
  return request.post("/role/getList", data)
}

export const addRoleApi = (
  data: RoleStructure
): Promise<ApiResponse<RoleStructure>> => {
  return request.post("/role/create", data)
}

export const updateRoleApi = (
  data: Partial<RoleStructure>
): Promise<ApiResponse> => {
  return request.post("/role/update", data)
}

export const deleteRoleApi = (id: number): Promise<ApiResponse> => {
  return request.post("/role/delete", { id })
}
